
interface Circle {
  kind: 'circle'
  radius: number
}

interface Square {
  kind: 'square'
  sideLength: number
}

interface Triangle {
  kind: 'triangle'
  sideLength: number
}

// type Shape1 = Circle | Square | Triangle
type Shape1 = Circle | Square 

function getArea1(shape: Shape1) {
  switch(shape.kind) {
    case 'circle': return Math.PI *shape.radius ** 2
    case 'square': return shape.sideLength ** 2
    // 有 Triangle 类型 shape 就不是 never 了，会报错
    default: const _exhaustiveCheck: never = shape; return _exhaustiveCheck 
  }
}
